class Solution:
	# @param matrix, a list of lists of integers
	# RETURN NOTHING, MODIFY matrix IN PLACE.
	def setZeroes(self, matrix):
		n = len(matrix)
		if n == 0:
			return
		m = len(matrix[0])
		for i in xrange(n):
			for j in xrange(m):
				if matrix[i][j] == 0:
					for k in xrange(m):
						if matrix[i][k] != 0:
							matrix[i][k] = None
					for q in xrange(n):
						if matrix[q][j] != 0:
							matrix[q][j] = None
		for i in xrange(n):
			for j in xrange(m):
				if matrix[i][j] is None:
					matrix[i][j] = 0

if __name__ == '__main__':
	so = Solution()

	a = [
		[1,2,0,0,1,2],
		[0,1,1,1,1,1],
		[3,3,3,3,3,3]
	]

	so.setZeroes(a)

	print a